//
//  HMVistorTableViewController.m
//  HMWeiBoOC
//
//  Created by GD on 16/9/20.
//  Copyright © 2016年 geduo. All rights reserved.
//

#import "HMVistorTableViewController.h"
#import "HMVisitorView.h"
#import "UIBarButtonItem+Extention.h"
#import "HMOAuthViewController.h"
#import "HMNavigationViewController.h"
#import "HMUserAccountViewModel.h"

@interface HMVistorTableViewController ()

@end

//BOOL isLogin = NO;

@implementation HMVistorTableViewController
    
-(BOOL)isLogin{
    return [HMUserAccountViewModel sharedViewModel].isLogin;
}

-(void)loadView{

    if (self.isLogin) {
       
        [super loadView];
    }else{
        _visitorView = [HMVisitorView visitorView];
        _visitorView.loginBlock = ^(){
            NSLog(@"我是从闭包调用过里的");
            HMOAuthViewController *oauthVc = [[HMOAuthViewController alloc] init];
            
            [self presentViewController:[[HMNavigationViewController alloc]initWithRootViewController:oauthVc ] animated:YES completion:nil];
        };
        self.view = _visitorView;
        
         [self setupNavUI];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

-(void)setupNavUI{
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initwithTitle:@"登录" imageName:nil target:self action:@selector(loginAciton)];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initwithTitle:@"注册" imageName:nil target:self action:@selector(loginAciton)];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    
}

-(void)loginAciton{
    NSLog(@"登录");
    
    HMOAuthViewController *oauthVc = [[HMOAuthViewController alloc] init];
    
    [self presentViewController:[[HMNavigationViewController alloc]initWithRootViewController:oauthVc ] animated:YES completion:nil];
}

@end
